package com.liuzu.esys.controller;

import com.liuzu.esys.common.LayuiPageVo;
import com.liuzu.esys.common.R;
import com.liuzu.esys.pojo.FinUser;
import com.liuzu.esys.service.FinUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author : 松松
 * @date : 2022/7/26
 * @desc : 员工工资财务功能实现
 */

@RestController
@RequestMapping("/finuser")
public class FinUserController {

    @Autowired
    private FinUserService finUserService;

    //查询员工工资财务列表
    @RequestMapping("/fulist")
    public LayuiPageVo<FinUser> finUserLayuiPageVo(@RequestParam Map<String, Object> params) {
        return finUserService.fuList(params);
    }

    //添加员工工资财务信息
    @RequestMapping("/fuadd")
    public R fuadd(FinUser finUser) {
        int flag = finUserService.addfu(finUser);

        if (flag == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }


    //删除员工工资财务信息
    @GetMapping("/fudel")
    public R fudel(Integer id) {
        int flag = finUserService.delfu(id);
        if (flag == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }


    //修改员工工资财务信息
    @GetMapping("fuset")
    public R fuset(FinUser finUser) {
        int flag = finUserService.setfu(finUser);
        if (flag == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }


}
